package com.wondertek.applet.controller.business;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wondertek.common.base.Result;
import com.wondertek.service.dto.app.req.AppRoomPageReq;
import com.wondertek.service.dto.app.req.AppRoomSelectByUserIdReq;
import com.wondertek.service.dto.app.req.AppRoomUpdateModeReq;
import com.wondertek.service.dto.app.res.AppRoomSelectByUserIdRes;
import com.wondertek.service.entity.business.RoomPo;
import com.wondertek.service.sdk.iotdh.dto.res.SetAreaArmModeRes;
import com.wondertek.service.service.business.RoomService;
import com.wondertek.service.service.business.SiteService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: 房间管理
 * @author: qinjianhui
 * @create: 2024-07-16 14:01
 **/
@RestController
@RequestMapping("/app/business/room/")
@Tag(name = "房间管理")
@CrossOrigin
public class RoomController {

    @Resource
    private RoomService roomService;

    @Resource
    private SiteService siteService;

//    @PostMapping("/add")
//    @Operation(summary = "新增房间")
//    public Result<?> addSite(@RequestBody RoomAddReq adminAddReq){
//        roomService.addRoom(adminAddReq);
//        return Result.success();
//    }

    @PostMapping("/page")
    @Operation(summary = "查询房间")
    public Result<Page<RoomPo>> page(@RequestBody AppRoomPageReq req){
        return Result.success(roomService.page(req));
    }

    @PostMapping("/selectByUserId")
    @Operation(summary = "查询房间")
    public Result<List<AppRoomSelectByUserIdRes>> selectByUserId(@RequestBody AppRoomSelectByUserIdReq req){
        return Result.success(roomService.selectByUserId(req));
    }

    @PostMapping("/findRoomByDcId")
    @Operation(summary = "根据deviceId和app用户id查询租赁分区")
    public Result<Page<AppRoomSelectByUserIdRes>> findRoomByDcId(@RequestBody AppRoomPageReq req) {
        return Result.success(roomService.findRoomByDcId(req));
    }



    @PostMapping("/updateMode")
    @Operation(summary = "更改布防模式")
    public Result<SetAreaArmModeRes> updateMode(@RequestBody @Validated AppRoomUpdateModeReq req){
        return roomService.updateMode(req);
    }

}

